home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / pdrd2.zip / RD.ZIP / RD_DEMO4.PRG < prev    next >
Text File  |  1993-01-11  |  3KB  |  77 lines

  1. /*
  2.     RD_DEMO4.PRG
  3.  
  4.     Demonstrates the use of the following APIs:
  5.     1.  ADr_keys() - defines hot keys and a hot key handler.
  6.     2.  ADr_exit() - defines an Exit Block to validate the Read, when
  7.                      attempting to exit.
  8.     3.  ADr_filled() - checks if specified Gets have been filled with data.
  9.     4.  ADr_blank() - blanks or empties specified Gets.
  10. */
  11.  
  12. #include "read.ch"
  13. #include "inkey.ch"
  14.  
  15. //---------
  16. func main()
  17. local getlist[0]
  18. local cShort := "Short string"
  19. local cLong := "This is a very long string.  It is '@S PICTUREd'.  This is the last of three sentences."
  20. local nNumber := 9
  21. local lLogical := .t.
  22. local dDate := date()
  23. local aArray := { "Frankie", "Library" }
  24. local nT := 0, nL := 10, nB := 8, nR := 50
  25. local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
  26. local aScn, aScn2
  27. local bConfig := {|e| ADr_keys( e, { K_F7, K_F8, K_F9, K_F10 },;
  28.                                    {|e,nth,nkey|Xkeys4(e,nth,nkey)};
  29.                               ),;
  30.                       ADr_exit( e, {|e| ADr_filled( e,;
  31.                                                     { 1, 2, 5 },;
  32.                                                     {|| ADmessage({ "Fields 1, 2, and 5 may not be left blank"})};
  33.                                                   );
  34.                                    };
  35.                               );
  36.                  }
  37. cls
  38. aScn = ADbox( nT, nL, nB, nR )
  39. @nT+1, nL+2 say "Short String" adget cShort
  40. @nT+2, nL+2 say "Long String " adget cLong picture "@S24"
  41. @nT+3, nL+2 say "Numeric     " adget nNumber
  42.  
  43. @nT+4, nL+2 say "Logical     " adget lLogical
  44. @nT+5, nL+2 say "Date        " adget dDate
  45. @nT+6, nL+2 say "Array Elem1 " adget aArray[1]
  46. @nT+7, nL+2 say "Array Elem2 " adget aArray[2]
  47. aScn2 = ADmessage( { "The following are hot keys:",;
  48.                      "  F7 - blanks the current Get",;
  49.                      "  F8 - blanks Get #2",;
  50.                      "  F9 - blanks Get #s 6 and 7",;
  51.                      "  F10 - blanks all Gets",;
  52.                      "",;
  53.                      "The Read will not be saved if any of Get #s 1, 2, or 5",;
  54.                      "is empty";
  55.                     }, 13,, .f., .f. )
  56. ADread( getlist, bConfig )
  57. ADrestscn( aScn )
  58. ADrestscn( aScn2 )
  59. setcolor( cColor )
  60. return nil
  61.  
  62.  
  63. //-----------------------
  64. func Xkeys4(e, nth, nkey )
  65. if nth = 1
  66.     ADr_blank( e )
  67. elseif nth = 2
  68.     ADr_blank( e, 2 )
  69. elseif nth = 3
  70.     ADr_blank( e, { 6, 7 } )
  71. elseif nth = 4
  72.     ADr_blank( e, {} )
  73. endif
  74. return nil
  75.  
  76.  
  77.